﻿using System;
using System.Collections.Generic;
using System.Data.Objects;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataAccessObject.DAO
{
    public class KhoiLopDAO
    {
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public List<KHOILOP> getAllKhoiLop()
        {
            using (QLHVEntities entities = new QLHVEntities())
            {
                return entities.KHOILOPs.ToList();
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="khoilop"></param>
        /// <returns></returns>
        public List<MONHOC> getAllMonHocByKhoiLop(KHOILOP khoilop)
        {
            using (QLHVEntities entities = new QLHVEntities())
            {
                var query = from data in entities.CHITIETMONHOCs
                            where data.KhoiLopId == khoilop.KhoiLopId
                            select data.MONHOC;
                return query.ToList();
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="monhoc"></param>
        /// <returns></returns>
        public List<KHOILOP> getKhoiLopByMonHoc(MONHOC monhoc)
        {
            using (QLHVEntities entities = new QLHVEntities())
            {
                var listKhoiLop = (from data in entities.CHITIETMONHOCs
                                  where data.MonHocId == monhoc.MonHocId
                                  select data.KHOILOP).ToList();
                return listKhoiLop;
            }
        }
    }
}
